package com.w3coffee.web.control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

/**
 * Ajax servlet.
 * @author Administrator
 *
 */
public class AjaxController extends BaseController {

	@Override
	public ModelAndView handleRequest(HttpServletRequest req,
			HttpServletResponse resp) throws Exception {
		CheckinToken token = (CheckinToken) req.getSession(false).getAttribute("TOKEN");
		double longitude = Double.parseDouble(req.getParameter("lng"));
		double latitude = Double.parseDouble(req.getParameter("lat"));
		double accuracy = Double.parseDouble(req.getParameter("acy"));
		token.setLongitude(longitude);
		token.setLatitude(latitude);
		token.setAccuracy(accuracy);
		
		resp.setContentType("text/xml");
		resp.setHeader("Cache-Control", "no-cache");
		resp.getWriter().write("<message>ok</message>"); 
		resp.flushBuffer();
		return null;
	}

}
